package yt.demo.appcoresystem.impl;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yt.demo.appcommondb.base.BaseService;
import yt.demo.appcommondb.vo.ConditionVO;
import yt.demo.appcoresystem.entity.SystemLoginLog;
import yt.demo.appcoresystem.mapper.SystemLoginLogMapper;
import yt.demo.appcoresystem.service.ISystemLoginLogService;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class SystemLoginLogService extends BaseService<SystemLoginLog, SystemLoginLogMapper> implements ISystemLoginLogService {

    @Autowired
    public SystemLoginLogService(SystemLoginLogMapper mapper) {
        super(mapper, SystemLoginLog.class);
    }

    @Override
    protected List<ConditionVO<SystemLoginLog, ?>> whereConditions(SystemLoginLog params) {
        List<ConditionVO<SystemLoginLog, ?>> conditions = new ArrayList<>();
        if (ObjectUtil.isNotEmpty(params.getUsername())) {
            conditions.add(ConditionVO.createCondition(SystemLoginLog::getUsername, "like", params.getUsername()));
        }
        if (ObjectUtil.isNotEmpty(params.getStatus())) {
            conditions.add(ConditionVO.createCondition(SystemLoginLog::getStatus, "eq", params.getStatus()));
        }
        if (ObjectUtil.isNotEmpty(params.getSearchTime())) {
            conditions.add(ConditionVO.createCondition(SystemLoginLog::getLoginTime, "bet", params.getSearchTime()));
        }
        return conditions;
    }



}
